clear all; clc; close all;
R=100;
C=10e-13;
RC=R*C;
C=33e-6;
R=100;
RC=R*C;
tmod=10*RC;
T=RC/1000;
t=0:T:tmod;
fmin=1/tmod;
fmax=1/T/2;
f=fmin:((fmax-fmin)/100):fmax;
A=1;
K=nan(1,length(f));
for j=1:length(f)
E=A*sin(2*pi*f(j)*t);
U=nan(1,length(t));
dU=nan(1,length(t));
U(1)=E(1);
dU(1)=0;

for k=2:length(t)
U(k)=U(k-1)+dU(k-1)*T;
dU(k)=(E(k)-U(k))/RC;

end
Us=U(fix(end/2):end);
K(j)=(max(Us)-min(Us))/2;
end

figure;
plot(f,20*log(K));
xlabel('f,Hz');
ylabel('K');
